/*
 * VectorTest.cpp
 *
 *  Created on: 07-01-2011
 *      Author: Przemek
 */

#include "geometry/Vector.hpp"
#include "utils/MathUtils.hpp"

#define BOOST_TEST_MODULE Vector2D test
#include <boost/test/unit_test.hpp>
using namespace std;

BOOST_AUTO_TEST_CASE( lengthTest )
{
	Vector vector = Vector(3, 4);
	BOOST_CHECK_EQUAL(MathUtils::isEqual(vector.getLength(), 5.0f),true);
}

BOOST_AUTO_TEST_CASE( normalizeTest )
{
	const Vector vector = Vector(3, 4);
	BOOST_CHECK_EQUAL(MathUtils::isEqual(vector.normalize().getLength(), 1.0f),true);
}

BOOST_AUTO_TEST_CASE( negateOperatorTest )
{
	Vector vector = -Vector(1, 2);
	BOOST_CHECK_EQUAL(MathUtils::isEqual(vector.getX(), -1.0f),true);
	BOOST_CHECK_EQUAL(MathUtils::isEqual(vector.getY(), -2.0f),true);
}

BOOST_AUTO_TEST_CASE( plusOperatorTest )
{
	Vector vector = Vector(1, 2) + Vector(3, 5);
	BOOST_CHECK_EQUAL(MathUtils::isEqual(vector.getX(), 4.0f),true);
	BOOST_CHECK_EQUAL(MathUtils::isEqual(vector.getY(), 7.0f),true);
}

BOOST_AUTO_TEST_CASE( minusOperatorTest )
{
	Vector vector = Vector(1, 2) - Vector(3, 5);
	BOOST_CHECK_EQUAL(MathUtils::isEqual(vector.getX(), -2.0f),true);
	BOOST_CHECK_EQUAL(MathUtils::isEqual(vector.getY(), -3.0f),true);
}

BOOST_AUTO_TEST_CASE( multiplyOperatorTest )
{
	Vector vector = Vector(1, 2) * 3.0f;
	BOOST_CHECK_EQUAL(MathUtils::isEqual(vector.getX(), 3.0f),true);
	BOOST_CHECK_EQUAL(MathUtils::isEqual(vector.getY(), 6.0f),true);
}

BOOST_AUTO_TEST_CASE( divideOperatorTest )
{
	Vector vector = Vector(10, 5) / 2.0f;
	BOOST_CHECK_EQUAL(MathUtils::isEqual(vector.getX(), 5.0f),true);
	BOOST_CHECK_EQUAL(MathUtils::isEqual(vector.getY(), 2.5f),true);
}
